package beans.bytee;

public class ByteDemo
{

	/**
	 * byte[]转为int
	 */
	private static void readInt()
	{
		byte[] bytes = new byte[4];
		bytes[0] = 0;
		bytes[1] = 0;
		bytes[2] = 0;
		bytes[3] = -67;
		System.out.println(ByteUtils.readInt(bytes, 0));
	}

	/**
	 * int转为 byte[]
	 */
	private static void writeInt()
	{
		byte[] bytes = new byte[4];
		ByteUtils.writeInt(bytes, 65534, 0);
		for (int i = 0; i < bytes.length; i++)
			System.out.println(i + " >> " + bytes[i]);

		int j = 0;
		byte[] bytess = new byte[4];
		ByteUtils.writeInt(bytess, 7, 0);
		for (byte b : bytess)
			System.out.println("bytess[" + j++ + "]" + b);

	}

	private static void char2int()
	{
		String ssString = "abcdefg";
		for (int i = 0; i < ssString.length(); i++)
			System.out.println(ssString.getBytes()[i]);
	}

	public static void main(String[] args)
	{
		readInt();
		System.out.println("==========================");
		writeInt();
		System.out.println("==========================");
		char2int();
	}

}
